package com.demo.mapper;

import com.demo.bean.PersonMysql;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface PersonMapper {
    List<PersonMysql> getPerson();

    PersonMysql getPersonById(int id);

    //SQL使用注解,表字段名需要与实体类中一致
    //方法存在多个参数,所有的参数必须加上Param
    @Select("select * from person where id=#{id}")
    PersonMysql getPersonByIdValeus(@Param("id") int myid);

    PersonMysql getPersonIF(Map<String, Object> map);

    PersonMysql getPersonChoose(Map<String, Object> map);

    int addPerson(PersonMysql personMysql);

    int updatePersonSet(Map<String, Object> map);

    int addPerson_2(Map<String, Object> map);

    @Select("insert into person(name, age, sex) values (#{name}, #{age}, #{sex})")
    void addPerson_3(PersonMysql personMysql);

    int updatePerson(PersonMysql personMysql);

    @Update("update person set name=#{name},age=#{age} where id = #{id};")
    int updatePersion_2(PersonMysql personMysql);

    int deletePerson(int id);

    List<PersonMysql> getPersonByLimit(Map<String, Integer> map);

    List<PersonMysql> getPersonForeach(Map<String, Object> map);
}
